<!DOCTYPE HTML>
<html>
<head>
    <title>Todo</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body  style="padding: 0;width: 100%;height: 100%;margin: 0">
<div class="mini-toolbar" style="text-align: center; line-height: 30px; border: 0px;" borderstyle="border:0;">
    <span>用户昵称：</span><input  class="mini-textbox" type="text" id="nickName"/>

    <span>用户id：</span><input  class="mini-textbox" type="text" id="objectId"/>

    <input style="margin-right: 30px" type="button" value="查找" onclick="search()"/>
</div>
<div id="datagrid1" class="mini-datagrid" style="width:100%;height: 80%"
     url="/getdata/usersInformation" idField="id" allowResize="true"
     sizeList="[10,30,50,100]" pageSize="10"
>
    <div property="columns">
        <div type="checkcolumn" width="20" ></div>
        <div field="objectId" width="120" headerAlign="center" allowSort="true" >用户id</div>
        <div field="nickName" width="80" headerAlign="center" allowSort="true" >用户昵称</div>
        <div name="action" width="60" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">后台登陆权限</div>
        <div field="gender"  width="50" align="center" headerAlign="center" renderer="onIconRenderer" allowSort="true" >用户头像</div>
        <div field="createAt" width="100" renderer="onBirthdayRenderer" align="center" headerAlign="center" allowSort="true">创建日期</div>
    </div>
</div>
<div class="mini-toolbar" style="text-align: center; padding-top: 8px; padding-bottom: 8px; border: 0px;" borderstyle="border:0;">
    <a class="mini-button" href="javascript:void(0)"  style="width: 60px;"><span class="mini-button-text " onclick="onOk()">确定</span></a>
    <span style="display:inline-block;width:25px;"></span>
    <a class="mini-button" href="javascript:void(0)"  style="width: 60px;"><span class="mini-button-text " onclick="onCancel()">取消</span></a>
</div>

</body>
<script type="text/javascript">
    //    var userStatus = [{ id: 1, text: '审核成功' }, { id: 0, text: '未审核'},{ id: 4, text: '审核失败'},{ id: 3, text: '审核中'}];
    var flag = 1;
    mini.parse();
    var grid = mini.get("datagrid1");

    grid.load();
    grid.on("drawcell", function (e) {
        var  value = e.value;
        column = e.column;
        //将性别文本替换成图片
        if (column.field == "gender") {
            if(value) {
                e.cellHtml = '<img class="bigImg" onclick="bigImg()" src="' + value + '?imageMogr2/thumbnail/640x/format/jpg/interlace/1/auto-orient" width="30" height="30" alt="图片">';
            }else{
                e.cellHtml = '<img class="bigImg" onclick="bigImg()"  src="http://7xiuo5.com1.z0.glb.clouddn.com/fgImage.png?imageMogr2/auto-orient/thumbnail/!100x100r/gravity/Center/crop/100x100/quality/80/auto-orient" width="30" height="30" alt="图片">';
            }
        }
    });

    function search() {
        var nickName = mini.get("nickName").getValue();
        var objectId = mini.get("objectId").getValue();
        grid.load({
            nickName: nickName,
            objectId:objectId,
        });
    }
    $("#nickName,#objectId").bind("keydown", function (e) {
        if (e.keyCode == 13) {
            search();
        }
    });



    function onBirthdayRenderer(e) {
        var value = e.value;
        if (value) return mini.formatDate(value, 'yyyy-MM-dd hh:mm:ss');
        return "";
    }
    function statusRenderer(e) {
        var value = e.value;
        if (value==1) {
            return (value, '正常')
        }else if(value==0){
            return (value, '关闭')
        }
    };
    function GetSelecteds() {
        var rows = grid.getSelecteds();
        return rows;
    }
    function GetData() {
        var rows = grid.getSelecteds();
        var ids = [], texts = [];
        for (var i = 0, l = rows.length; i < l; i++) {
            var row = rows[i];
            ids.push(row.objectId);
            texts.push(row.name);
        }
        var data = {};
        data.id = ids.join(",");
        data.text = texts.join(",");
        return data;
    }

    //////////////////////////////////
    function CloseWindow(action) {
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function onOk() {
        CloseWindow("ok");
    }
    function onCancel() {
        CloseWindow("cancel");
    }
    function onActionRenderer(e) {
        var grid = e.sender;
        var record = e.record;
        var uid = record._uid;
        var rowIndex = e.rowIndex;
        var s = '<a class="Edit_Button" href="javascript:authRow(\'' + uid + '\')">授权</a> ';

        return s;
    }
    function authRow(row_uid) {
        var row = grid.getRowByUID(row_uid);
        if (row) {
            $.ajax({
                url: "/getdata/allow/adminLogin",
                type:"POST",
                data:{
                    userOId:row.objectId,
                    status:1
                },
                success: function (text) {
                    if (text==1){
                        alert("授权成功")
                    }else if(text==2){
                        alert("授权过")
                    }else{
                        alert("授权失败")
                    }
                }
            });
        }
    }
</script>
</html>